# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_gemname=rack-test
pkgname=ruby-${_gemname}
pkgver=2.0.2
pkgrel=2
pkgdesc='Small, simple testing API for Rack apps'
url='https://github.com/rack-test/rack-test'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-rack')
makedepends=('ruby-rdoc')
checkdepends=('ruby-rake' 'ruby-rspec' 'ruby-minitest' 'ruby-minitest-global_expectations')
options=('!emptydirs')
source=(https://github.com/rack-test/rack-test/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz)
sha256sums=('619bd3f633232abbc5fc03952463ce520fcf6281f092fdcf34151341fcb2c939')
sha512sums=('de91787563546a3f12da15f665975bf3d68f7633e277c86a529a728cb8ba9d78bac5c30c2ec1ece9aab5341571ceb23d8089d0da542409bdba23ebe93d75e2a5')

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec
  sed 's|git ls-files|find|' -i ${_gemname}.gemspec
}

build() {
  cd ${_gemname}-${pkgver}
  gem build ${_gemname}.gemspec
}

check() {
  cd ${_gemname}-${pkgver}
  rake spec
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" \
    -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README*.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 MIT-LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -r "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
